package xmlService;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import beans.CotizacionBean;
import beans.FinanciacionBean;
import beans.OrdenDePedidoBean;
import beans.PagoContadoBean;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import controller.ControllerPrincipal;

public class OrdenDePedidoXmlService {

	public static void main(String[] args) throws Exception {
		ControllerPrincipal.getInstancia().cargarSolicitudCotizacion();
		ControllerPrincipal.getInstancia().cargarOrdenPedido();
		
	}

	public static OrdenDePedidoBean cargarOdenDePedido()
	{
		OrdenDePedidoBean c = null;
		
		XStream xstream = new XStream( new DomDriver());
		xstream.autodetectAnnotations(true);  
		
		xstream.alias("OrdenDePedido", OrdenDePedidoBean.class);
		xstream.alias("PagoContado", PagoContadoBean.class);
		xstream.alias("Financiacion", FinanciacionBean.class);
		FileInputStream fis;
		try {
			fis = new FileInputStream("src/XML/OrdenPedido.xml");
			c = (OrdenDePedidoBean) xstream.fromXML(fis);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return c;				
	}

}
